package com.blb.mq02;

import com.blb.util.MQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 多对多模式的生产者，会发送多条消息到队列中
 */
public class WorkProductor {

    public static void main(String[] args) throws IOException, InterruptedException {
        Connection connection = MQUtils.getConnection();
        Channel channel = connection.createChannel();
        channel.queueDeclare(MQUtils.QUEUE_NAME,false,false,false,null);
        for(int i = 0;i < 100;i++){
            String msg = "Hello-->" + i;
            channel.basicPublish("",MQUtils.QUEUE_NAME,null, msg.getBytes());
            System.out.println("send:" + msg);
            Thread.sleep(10);
        }
        channel.close();
        connection.close();
    }
}
